import allure
from common.getlog import log
import inspect
from data.config import baseUrl
import json
class BaseApi:

    def logs(self, logMsg, logData=None):
        """
        打印log和allure日志
        :param logMsg:日志信息
        :param logData:日志数据
        """
        logMsg = self.__class__.__name__ + "-" + inspect.stack()[1][3] + "-" + logMsg

        if logData != None:
            if isinstance(logData, dict):
                logData = json.dumps(logData)
            log.info(logMsg + ":" + logData)
            allure.attach(logData, logMsg)
        else:
            log.info(logMsg)
            allure.attach(logData, "")

    def getUrl(self,url):
        """
        获取url
        :param url:
        :return:
        """
        return baseUrl+url

if __name__ == '__main__':
    dictory = {"key1": "value1", "key2": "value2"}
    print(type(dictory))